package com.falcon.modules.domain.bo;

import com.falcon.modules.domain.dto.Menu;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;

import java.io.Serializable;


public class UserRoleMenuBo implements Serializable, Comparable<UserRoleMenuBo> {

    private Long id;
    private Long pId;
    private String name;
    private boolean checked;
    private boolean open;
    private Integer sort;

    public UserRoleMenuBo(){}

    public UserRoleMenuBo(Menu menu){
        this.id = menu.getId();
        this.pId = menu.getPid();
        this.name = menu.getName();
        this.sort = menu.getSort();
//        if(this.pId > 0){
            this.open = true;
//        }
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getpId() {
        return pId;
    }

    public void setpId(Long pId) {
        this.pId = pId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public boolean isChecked() {
        return checked;
    }

    public void setChecked(boolean checked) {
        this.checked = checked;
    }

    public boolean isOpen() {
        return open;
    }

    public void setOpen(boolean open) {
        this.open = open;
    }

    public Integer getSort() {
        return sort;
    }

    public void setSort(Integer sort) {
        this.sort = sort;
    }

    @Override
    public int compareTo(UserRoleMenuBo o) {
        if(o==null){
            return 1;
        }
        if(this.pId!=null && this.pId > o.getpId()){
            return 1;
        }
        if(this.pId!=null && this.pId < o.getpId()){
            return -1;
        }
        if(this.sort!=null && this.sort > o.getSort()){
            return 1;
        }
        if(this.sort!=null && this.sort < o.getSort()){
            return -1;
        }
        return 0;
    }


}
